import { BasicTable, useTable, BasicColumn, FormSchema } from "@/components/Table";
import { outPatientsPage, deptList } from "@/api/ImmigrationDictionary";
import { useTranslation } from "react-i18next";
import "./index.less";

export default function index() {
	const { t } = useTranslation();

	const columns: BasicColumn[] = [
		{
			title: t("kevin_ui.call"),
			dataIndex: "call",
			render: (_, __, index) => index + 1
		},
		{
			title: t("kevin_ui.fingerprint"),
			dataIndex: "activeIngre"
		},
		{
			title: t("patientBasic.patient_id"),
			dataIndex: "patientId"
		},
		{
			title: t("patientBasic.full_name"),
			render: (text, record) => {
				return <p>{record.patients?.fullName}</p>;
			}
		},
		{
			title: t("kevin_ui.phone"),
			render: (text, record) => {
				return <p>{record.patients?.phoneNumb}</p>;
			}
		},
		{
			title: t("kevin_ui.birth_year"),
			render: (text, record) => {
				return <p>{record.patients?.birthyear}</p>;
			}
		},
		{
			title: t("kevin_ui.outpatient_number"),
			dataIndex: "opNo"
		},
		{
			title: t("kevin_ui.admission_date"),
			render: (text, record) => {
				return <p>{record.patients?.transDtime}</p>;
			}
		},
		{
			title: t("flandre_ui.place_of_transfer"),
			render: (text, record) => {
				return <p>{record.patientTrans?.transFrom}</p>;
			}
		},
		{
			title: t("flandre_ui.beneficiary"),
			render: (text, record) => {
				return <p>{record.patientInsur?.patSubject}</p>;
			}
		},
		{
			title: t("flandre_ui.pat_cardno"),
			dataIndex: "patCardno"
		},
		{
			title: t("flandre_ui.drug_days"),
			render: (text, record) => {
				return <p>{record.patientInsur?.insDefinedVdays}</p>;
			}
		},
		{
			title: t("kevin_ui.icd_code"),
			render: (text, record) => {
				return <p>{record.patientTrans?.referralIcd}</p>;
			}
		},
		{
			title: t("flandre_ui.rx_diagnosis"),
			render: (text, record) => {
				return <p>{record.patientTrans?.referralPaper}</p>;
			}
		},
		{
			title: t("flandre_ui.doctor"),
			dataIndex: "doctorId",
			render: (text, record) => {
				return <p>{record.patients?.citizenId}</p>;
			}
		},
		{
			title: t("kevin_ui.id_card_number"),
			dataIndex: "salePrice"
		}
	];
	const searchFormSchema: FormSchema[] = [
		{
			label: t("flandre_ui.dept_name"),
			field: "department",
			component: "ApiSelect",
			componentProps: {
				api: () => deptList(),
				labelField: "name",
				valueField: "id"
			}
		}
	];
	const [patServicesTable] = useTable({
		api: outPatientsPage,
		columns,
		useSearchForm: true,
		formConfig: {
			schemas: searchFormSchema,
			showActionButtonGroup: true
		}
	});

	return (
		<div className="outpatientMedicalRecord">
			<div className="page-content">
				<BasicTable register={patServicesTable}></BasicTable>
			</div>
		</div>
	);
}
